package student

import (
	"bysy-gin/handler/student"
	"bysy-gin/middleware"
	"github.com/gin-gonic/gin"
)

func Stu_Load(g *gin.Engine) {
	g.GET("/student", func(c *gin.Context) {
		c.String(200, "this is student")
	})
	g.GET("/getstudent", middleware.AuthMiddlerware(), student.GetStudent)
	g.GET("/addstu", func(c *gin.Context) {
		c.HTML(200, "addstudent.html", gin.H{})
	})
	g.POST("/addstu", student.AddStudent)
	g.DELETE("/deletestu", student.DeleteStudent)
	g.PUT("/modifystu", student.UpdateStu)
	g.GET("/getstubyidname", student.GetStuByIdName)

	//使用路由组，创建restful api
	stu_v1 := g.Group("/api/v1") //   /api/v1 相当于前缀
	//stu_v1.Use(middleware.AuthMiddlerware())  //为路由组添加中间件
	{
		stu_v1.GET("/student", student.GetStudent)
		stu_v1.POST("/student", student.AddStudent)
		stu_v1.DELETE("/student/:id", student.DeleteStudent)
		stu_v1.PUT("/student/:id", student.UpdateStu)
	}

}
